<template>
	<view>
		<!-- 顶部按钮区域 -->
		<view class="d-top">
			<view class="close" @click="close">
				<uni-icons type="closeempty" size="30px"></uni-icons>
			</view>
			<view class="scan">
				<uni-icons type="scan" size="30px" @click="scan"></uni-icons>
			</view>
		</view>
		<!-- 用户信息区域 -->
		<view class="me">
			<!-- 未登录状态 -->
			<view class="visitor" v-show="isLogin">
				<image class="avatar" src="../../static/icons/visitor.png" mode=""></image>
				<view class="name">
					<view class="b">未登录</view>
				</view>
			</view>
			<!-- 登录状态 -->
			<view class="user" v-show="!isLogin">
				<image class="avatar" :src="userInfo.avatar_url" mode=""></image>
				<view class="name">
					<view class="b">{{ userInfo.name}}</view>
					<view class="s">账户名：{{ userInfo.user_name}}</view>
				</view>
			</view>
		</view>
		<!-- 功能列表区域 -->
		<view class="func">
			<view class="func-item" @click="goList(userInfo.id)">
				<image src="../../static/icons/file-common.png"></image>
				<view>我的收藏</view>
			</view>
			<view class="func-item" @click="goHistory">
				<image src="../../static/icons/time.png"></image>
				<view>浏览历史</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	export default {
		name:"drawer-content-item",
		data() {
			return {
				
			};
		},
		computed: mapState(['isLogin','userInfo']),
		methods: {
			bindLogout() {
				this.$emit('bindLogout')
			},
			goList(uid) {
				if(!this.isLogin)
					uni.navigateTo({
						url: '../mov-list/mov-list?uid='+uid
					})
				else{
					uni.showToast({
						title: '当前未登录',
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '../login/login'
						})
					},1000)
				}
			},
			close() {
				this.$emit('closeDrawer')
			},
			scan() {
				this.$emit('scan')
			},
			goHistory() {
				uni.navigateTo({
					url: '../history/history'
				})
			}
		}
	}
</script>

<style lang="scss">
	.d-top{
		padding: 20px 10px 10px 10px;
		display: flex;
		text-align: center;
		.close{
			width: 40px;
			height: 40px;
			line-height: 40px;
			position: absolute;
			left: 10px;
		}
		.scan{
			width: 40px;
			height: 40px;
			position: absolute;
			right: 10px;
			float: right;
			line-height: 40px;
		}
	}
	.me{
		margin-top: 50px;
		.visitor{
			line-height: 50px;
			display: flex;
			margin: 10px 10px;
			padding-bottom: 10px;
			.avatar{
				width: 60px;
				height: 60px;
				border-radius: 50px;
			}
			.name{
				margin-top: 5px;
				margin-left: 10px;
				.dec{
					display: flex;
					margin-top: 8px;
					view{
						margin-right: 10px;
					}
				}
			}
		}
		.user{
			display: flex;
			margin: 10px 10px;
			padding-bottom: 10px;
			.avatar{
				width: 60px;
				height: 60px;
				border-radius: 50px;
			}
			.name{
				margin-top: 5px;
				margin-left: 10px;
				.dec{
					display: flex;
					view{
						margin-right: 10px;
					}
				}
			}
			.logout{
				display: inline-block;
				position: absolute;
				right: 10px;
				top: 80px;
				// #ifdef APP-PLUS
				top: 110px;
				// #endif
				text-align: center;
				image{
					width: 20px;
					height: 20px;
				}
			}
		}
	}
	.user{
		display: flex;
		margin: 50px 10px 10px 10px;
		padding-bottom: 10px;
		.avatar{
			width: 60px;
			height: 60px;
			border-radius: 50px;
		}
		.name{
			margin-left: 10px;
			.dec{
				display: flex;
				view{
					margin-right: 10px;
				}
			}
		}
	}
	.func{
		margin-left: 10px;
		.func-item{
			width: 112px;
			display: flex;
			margin-top: 20px;
			line-height: 30px;
			font-size: 18px;
			image{
				width: 30px;
				height: 30px;
			}
			view{
				margin-left: 10px;
			}
			.logout{
				width: 25px;
				height: 25px;
				margin-left: 2px;
			}
		}
	}
</style>
